import React, {Component} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import 'react-native-devsettings';
import Index from './Stacks/HomeStack';
import updateConfig from './update.json';
import {PushyProvider, Pushy} from 'react-native-update';

const {appKey} = updateConfig['ios'];

const pushyClient = new Pushy({
  appKey,
  // debug: true
});

/**
 * @description: 配置导航路由目录, 实现 Deeplink 跳转
 */
const linking = {
  prefixes: ['myschemes://', 'https://www.aaa.com'],
  config: {
    screens: {
      initialRouteName: 'BottomTabsNavigator',
      BottomTabsNavigator: {
        initialRouteName: 'Home',
        screens: {
          Home: 'home',
          Category: 'category',
          Cart: 'cart',
          Mine: 'mine',
        },
        path: '',
      },
      Detail: 'detail',
      Login: 'login',
      Register: 'register'
    },
  },
};

const initialState = {
  routes: [
    {
      name: 'BottomTabsNavigator',
      state: {
        index: 0,
        routes: [{name: 'Home'}],
      },
    },
  ],
};

/**
 * 测试数据
 * myschemes://detail?imageUrl=https://stageimg.sephorastatic.cn/dc/core/20240123/15/CfpZtHYQr_750x750.jpeg&title=跳转&levelUrl=https://stageimg.sephorastatic.cn/dc/upgradeicons/levelicons/38x34_icons/lv4_3x.png&nickname=老王
*/
export default class App extends Component {
  render() {
    return (
      <PushyProvider client={pushyClient}>
        <NavigationContainer initialState={initialState} linking={linking}>
          <Index />
        </NavigationContainer>
      </PushyProvider>
    );
  }
}